package net.wicp.tams.commons.callback.impl.column;

import java.sql.Timestamp;

import org.apache.tapestry5.json.JSONObject;

import net.wicp.tams.commons.callback.ICol;
import net.wicp.tams.commons.constant.DateFormatCase;

public class ColTimestamp implements ICol<Timestamp> {
	private static final long serialVersionUID = 1L;
	private final Timestamp timestamp;

	public ColTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
	}

	@Override
	public String toClient() {
		return DateFormatCase.YYYY_MM_DD_hhmmss.getInstanc().format(timestamp);
	}

	@Override
	public Timestamp toValue() {
		return timestamp;
	}

	@Override
	public JSONObject toJson(String colName) {
		return new JSONObject(colName, toClient());
	}
}
